package com.qianya.oa.controller.system;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qianya.oa.common.core.controller.BaseController;
import com.qianya.oa.domain.SysHospital;
import com.qianya.oa.service.HospitalInfoService;
import com.qianya.oa.util.CommonResult;
import com.qianya.oa.vo.SysHospitalVo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author swh
 */
@Slf4j
@RestController
@RequestMapping(value = "/sale")
@Api(tags = {"医院信息管理"})
public class HospitalController extends BaseController {

    @Resource
    private HospitalInfoService hospitalInfoService;

    @RequiresRoles(value = {"admin","boss","hr"},logical = Logical.OR)
    @PostMapping("/del")
    public CommonResult<?> deleteHospitalService(@RequestParam(name = "id")Integer id){
        return CommonResult.success(hospitalInfoService.deleteHospitalById(id));
    }
    @PostMapping("/selectHospitalInfo")
    public CommonResult<?> selectHospitalInfo(@RequestParam("pageNum") Integer pageNum,@RequestParam("pageSize")  Integer pageSize,@RequestParam("hospitalName") String hospitalName,@RequestParam("hospitalLv")String hospitalLv){
        SysHospital sysHospital = new SysHospital();
        sysHospital.setHospitalName(hospitalName);
        sysHospital.setHospitalLv(hospitalLv);
        return CommonResult.success(hospitalInfoService.selectAllHospitalServices(pageNum,pageSize,sysHospital));
    }

    @PostMapping("/addHospitalInfo")
    public CommonResult<?> addHospitalInfo(@RequestBody SysHospital sysHospital){
        return CommonResult.success(hospitalInfoService.addHospital(sysHospital));
    }

    @GetMapping("/getConfrimHospitalInfo")
    public CommonResult<?> getConfrimHospital(@RequestParam("pageNum") Integer pageNum,@RequestParam("pageSize")Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<SysHospitalVo> pageInfo = new PageInfo<>(hospitalInfoService.selectConfrimHospital());
        return CommonResult.success(pageInfo);
    }

    @GetMapping("/getUnConfrimHospitalInfo")
    public CommonResult<?> getUnConfrimHospitalInfo(@RequestParam("pageNum") Integer pageNum,@RequestParam("pageSize")Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<SysHospitalVo> pageInfo = new PageInfo<>(hospitalInfoService.selectUnConfrimHospital());
        return CommonResult.success(pageInfo);
    }

}
